home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 1996 September / Software of the Month Club 1996 September.iso / mac / Software Research Institute-SRI / Business / Alpha ƒ / Tcl / SystemCode / menus.tcl < prev    next >
Encoding:
Text File  |  1996-01-07  |  9.5 KB  |  500 lines  |  [TEXT/ALFA]

  1. # My menus.        
  2.  
  3. menu -n File -p fileMenuProc {
  4.     "/Nnew"
  5.     "/Oopen╔"
  6.     {menu -n recent {}}
  7.     "<S/Wclose"
  8.     "<S<I<O/WcloseAll"
  9.     "(-"
  10.     "<S/Ssave"
  11.     "<S<I<O/SsaveAll"
  12.     "<SsaveACopyAs╔"
  13.     "<SsaveAs╔"
  14.     "revert"
  15.     "(-"
  16.     "<S/Y<Oshell"
  17.     "<S/Y<B<OtoolserverShell"
  18.     "(-"
  19.     "pageSetup╔"
  20.     {menu -n print {}}
  21.     "(-"
  22.     "/Qquit"
  23. }
  24.  
  25.  
  26. proc fileMenuProc {menu item} {
  27.     if {$item == "open"} {
  28.         findFile
  29.     } elseif {$item == "close"} {
  30.         killWindow
  31.     } else {
  32.         $item
  33.     }
  34. }
  35.  
  36.  
  37. menu -n Edit {
  38.     "/Zundo"
  39.     "/Z<I<Oredo"
  40.     "/Lload"
  41.     "(-"
  42.     "/X<Scut"
  43.     "/X<S<I<Ocut&Append"
  44.     "/C<Scopy"
  45.     "/C<S<I<Ocopy&Append"
  46.     "/V<Spaste"
  47.     "/V<S<I<OpastePop"
  48.     "/A<SselectAll"
  49.     "/A<S<I<OselectParagraph"
  50.     "clear"
  51.     "(-"
  52.     {menu -n emacs {}}
  53.     "/`<Stwiddle"
  54.     "/`<S<I<OtwiddleWords"
  55.     "(-"
  56.     {/[<SshiftLeft}
  57.     {/[<S<I<OshiftLeftSpace}
  58.     {/]<SshiftRight}
  59.     {/]<S<I<OshiftRightSpace}
  60.     "/Bbalance"
  61. }
  62.  
  63.  
  64. menu -n Search {
  65.     "/F<Sfind╔"
  66.     "/F<S<I<OsearchStart"
  67.     "/G<SfindAgain"
  68.     "/G<S<I<OfindAgainBackward"
  69.     "/H<I<OfindInNextFile"
  70.     "/E<SenterSearchString"
  71.     "/E<S<I<OenterReplaceString"
  72.     "(-"
  73.     "/S<BquickFind"
  74.     "/R<BreverseQuickFind"
  75.     "(-"
  76.     "/Rreplace"
  77.     "/Hreplace&FindAgain"
  78.     "<S/R<O<IreplaceAll"
  79.     "<S/R<O<I<BreplaceInFileset"
  80.     "(-"
  81.     "/,<BpushPosition"
  82.     "/.<BpopPosition"
  83.     "/G<IgotoLine"
  84. }
  85. proc pushPosition {} {pushMark}
  86. proc popPosition {} {popMark}
  87. #     {menu -n NamedClipboards -p namedClipMenuProc {"copy╔" "cut╔" "paste╔"}}
  88. #     {menu -n registers { pointToRegister jumpToRegister }}
  89.  
  90. proc namedMarkProc {menu item} {
  91.     switch $item {
  92.         "markFile"            {markFile; message "File marked."}
  93.         "set"                 {setNamedMark}
  94.         "goto"                {gotoFileMark}
  95.         "remove"            {removeNamedMark}
  96.         "sort"                {sortMarksFile}
  97.         "sortByPosition"    {orderMarks}
  98.     }
  99. }
  100.  
  101. proc unnamedMarkproc {menu item} {
  102.     switch $item {
  103.         "set"                     {setMark}
  104.         "exchangePointAndMark"    {exchangePointAndMark}
  105.         "hilite"                {markHilite}
  106.     }
  107. }
  108.     
  109. proc installProc {menu item} {
  110.     switch $item {
  111.         "Electric Alias"     {loadElectricAlias}
  112.         "LaTeX 2.09"        {loadLaTeX}
  113.         "LaTeX2e"            {loadLaTeX}
  114.         "MacPerl"            {loadMacPerl}
  115.     }
  116. }
  117.  
  118.  
  119. menu -n "Utils" {
  120.         {menu -n fileUtils {
  121.             "insertPathName╔"
  122.             "insertFile╔"
  123.             "fileRemove╔"
  124.             "fileInfo╔"
  125.             "wordCount"}}
  126.         {menu -m -n compare -p compareProc {
  127.             "Windows"
  128.             "Files╔"
  129.             "Directories╔"}}
  130.         {menu -n asciiEtc {
  131.             "quoteChar"
  132.             "(-"
  133.             "keyCode"
  134.             "keyAscii"
  135.             "getAscii"
  136.             "insertAscii"}}
  137.         {menu -n KbdMacros {
  138.             "/qstartKeyboardMacro"
  139.             "/rendKeyboardMacro"
  140.             "/sexecuteKeyboardMacro"
  141.             "dumpMacro"}}
  142.         "(-"
  143.         "sendUrl"
  144.         {menu -m -n switchTo -p switchProc {}}
  145.         {menu -n internetConfig -p internetProc {
  146.             goTo
  147.             help
  148.             (-
  149.             webBrowser
  150.             newsClient
  151.             mailClient
  152.             (-
  153.             ftpClient
  154.             gopherClient
  155.             telnetClient
  156.             (-
  157.             resolveUrl
  158.             viewHtmlFile
  159.         }}
  160.         "(-"
  161.         "/M<I<OmatchingLines"
  162.         "gotoMatch"
  163.         "/inextMatch"
  164.         "(-"
  165.         "/jcmdDoubleClick"
  166.         "/kdescribeBinding"
  167.         "listBindings"
  168.         "listFunctions"
  169. }
  170.  
  171.  
  172. proc compareProc {menu item} {
  173.     catch {compare$item} msg
  174.     message $msg
  175. }
  176.  
  177. proc namedClipMenuProc {menu item} {
  178.     switch $item {
  179.         "copy"         "copyNamedClipboard"
  180.         "cut"         "cutNamedClipboard"
  181.         "paste"     "pasteNamedClipboard"
  182.     }
  183. }
  184.  
  185.         
  186. menu    -n Config {
  187.     {menu -s -n mode -p editModeFlag {}}
  188.     {menu -s -n flags -p editFlag {}}
  189.     {menu -s -n vars -p editVar {}}
  190.     {menu -n Menus -p addMenuProc {"Add╔" "Remove╔"}}
  191.     "(-"
  192.     {menu -n appPaths {}}
  193.     {menu -m -n install -p installProc {
  194.         "Electric Alias"
  195.         "Rudimentary Eudora Interface"
  196.         "(-"
  197.         "LaTeX2e"
  198.         "LaTeX 2.09"
  199.     }}
  200.     "(-"
  201.     "/lsetFontsTabs╔"
  202.     {menu -n redefineColors -p colorProc {
  203.         foreground
  204.         background
  205.         "(-"
  206.         blue
  207.         cyan
  208.         green
  209.         magenta
  210.         red
  211.         white
  212.         yellow
  213.         "(-"
  214.         color_9
  215.         color_10
  216.         color_11
  217.         color_12
  218.         color_13
  219.         color_14
  220.         color_15}}
  221.     "(-"
  222.     "viewSavedSetting╔"
  223.     "removeSavedSetting╔"
  224.     "(-"
  225.     "editPrefs.tcl"
  226.     "editCurrentModePrefs"
  227.     "sourceCurrentModePrefs"
  228.     "menu -n modePrefs -p editPrefsProc {}"
  229. }
  230.  
  231. # proc addMenuProc {menu item} {
  232. #     global modeMenus menuTrans mode
  233. #     if {$item == "Add╔"} {
  234. #         foreach m [concat $modeMenus(global) $modeMenus($mode)] {
  235. #             if {[info exists menuTrans($m)]} {
  236. #                 lappend menus "$menuTrans($m)"
  237. #                 set reverseTrans($menuTrans($m)) $m
  238. #             } else {
  239. #                 lappend menus $m
  240. #             }
  241. #         }
  242. #         
  243. #         set menus [listpick -l -p "Add which menus?" [lsort $menus]]
  244. #         foreach m $menus {
  245. #             if {[info exists reverseTrans($m)]} {
  246. #                 lappend mens $reverseTrans($m)
  247. #             } else {
  248. #                 lappend mens $m
  249. #             }
  250. #         }
  251. #         switch [buttonAlert "Add globally or to mode '$mode'?" "Global" $mode "Cancel"] {
  252. #         }
  253. #     }
  254. # }
  255.  
  256.  
  257. proc colorProc {menu item} {
  258.     global colorInds modifiedArrVars
  259.     if {[info exists colorInds($item)]} {
  260.         set color [eval [list colorTriple "New \"$item\":"] $colorInds($item)]
  261.     } else {
  262.         switch $item {
  263.             foreground    { set inds "0 0 0" }
  264.             background    { set inds "65535 65535 65535" }
  265.             blue        { set inds "0 0 65535" }
  266.             cyan        { set inds "61404 11464 34250" }
  267.             green        { set inds "1151 33551 8297" }
  268.             magenta        { set inds "44790 1591 51333" }
  269.             red            { set inds "65535 0 0" }
  270.             white        { set inds "65535 65535 65535" }
  271.             yellow        { set inds "61834 64156 12512" }
  272.             default        { set inds "65535 65535 65535" }
  273.         }
  274.         set color [eval [list colorTriple "New \"$item\":"] $inds]
  275.     }
  276.     eval setRGB $item $color
  277.  
  278.     set colorInds($item) $color
  279.     lappend modifiedArrVars colorInds
  280. }
  281.  
  282.  
  283.         
  284. # ==== NOTE:  rectMarkHilite, onespace, centerRedraw, doTab
  285. menu    -n Text {
  286.         "/I<SfillParagraph"
  287.         "/I<S<O<IwrapParagraph"
  288.         "/I<S<O<I<BsentenceParagraph"
  289.         "/U<S<OfillRegion"
  290.         "/U<S<I<OwrapRegion"
  291.         "<E<SparagraphToLine"
  292.         "<SlineToParagraph"
  293.         "(-"
  294.         "<SreverseSort"
  295.         "<SsortLines"
  296.         "/L<I<OspellcheckWindow"
  297.         "(-"
  298.         "zapInvisibles"
  299.         "<SspacesToTabs"
  300.         "<StabsToSpaces"
  301.         "<S<EindentRegion"
  302.         "<SindentLine"
  303.         "<E<SdowncaseRegion"
  304.         "<SupcaseRegion"
  305.         "(-"
  306.         {menu -n Strings {
  307.             "<SremovePrefix"
  308.             "<SinsertPrefix"
  309.             "<S<EremoveSuffix"
  310.             "<SinsertSuffix"
  311.             "setPrefix"
  312.             "setSuffix"
  313.             }}
  314.         "/D<ScommentLine"
  315.         "/D<S<I<OuncommentLine"
  316.         "<SuncommentBox"
  317.         "<ScommentBox"
  318.         "<S<EuncommentParagraph"
  319.         "<ScommentParagraph"
  320.         "(-"
  321.         "/=markHilite"
  322.         {menu -n namedMarks -p namedMarkProc {
  323.             "/K<O<Sset╔"
  324.             "/K<O<B<SmarkFile"
  325.             "/K<I<Ogoto╔"
  326.             "remove╔"
  327.             "(-"
  328.             "sort"
  329.             "sortByPosition"}}
  330.         {menu -n unnamedMarks -p unnamedMarkproc {
  331.             "set╔"
  332.             "exchangePointAndMark"}}
  333. }
  334.  
  335. proc strip {arg} {
  336.     if {[regsub -all {\\([][\{\}])} $arg {\1} v]} {return $v}
  337.     return $arg
  338. }
  339.  
  340.  
  341. #===============================================================================
  342. proc helpMenu {item} {
  343.     global HOME
  344.     if {$item == "Alpha Manual"} {
  345.         edit -r "$HOME:Help:Manual"
  346.     } else {
  347.         edit -r "$HOME:Help:$item"
  348.     }
  349. }
  350. set men { "Alpha Manual" "Alpha Commands" "Tcl Commands" "(-" "Quick Start" "Readme" "Changes" "(-" }
  351. foreach f [lsort -ignore [glob "$HOME:Help:*"]] {
  352.     set f [file tail $f]
  353.     if {($f != "Manual") && ($f != "Quick Start") && ($f != "Readme") && ($f != "Changes") && ($f != "ToDo") && ($f != "Alpha Commands") && ($f != "Tcl Commands")} {
  354.         lappend men $f
  355.     }
  356. }
  357. foreach f $men {
  358.     addHelpMenu $f
  359. }
  360. unset men
  361. #===============================================================================
  362.  
  363.  
  364. proc escapeSpaces {str} {
  365.     regsub -all { } $str {\ } str2
  366.     return $str2
  367. }
  368.  
  369.  
  370. proc buildSwitches {} {
  371.     global switchApps
  372.     
  373.     menu -m -n switchTo -p switchProc {"<O<I/NNow╔" "Add╔" "Remove╔" "(-"}
  374.  
  375.     if {[info exists switchApps] && [llength $switchApps]} {
  376.         foreach app $switchApps {
  377.             lappend names [file tail $app]
  378.         }
  379.         foreach name [lsort -ignore $names] {
  380.             addMenuItem -m -l "blah" switchTo $name
  381.         }
  382.     }
  383. }
  384.  
  385.  
  386. proc switchProc {menu name} {
  387.     global switchTo switchApps
  388.  
  389.     if {$name == "Add"} {
  390.         set fname [getfile "Pick an app:"]
  391.         lappend switchApps $fname
  392.         addDef switchApps $switchApps
  393.         buildSwitches
  394.     } elseif {$name == "Remove"} {
  395.         foreach app $switchApps {
  396.             lappend apps [file tail $app]
  397.         }
  398.         set name [listpick -p "Remove which app?" $apps]
  399.         if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
  400.             set switchApps [lreplace $switchApps $ind $ind]
  401.             addDef switchApps $switchApps
  402.             buildSwitches
  403.         }
  404.     } elseif {$name == "Now"} {
  405.         switchApp
  406.     } else {
  407.         if {[set ind [lsearch $switchApps "*$name"]] >= 0} {
  408.             if {[catch {switchTo $name}]} {
  409.                 launch -f [lindex $switchApps $ind]
  410.             }
  411.         }
  412.     }
  413. }
  414.         
  415.  
  416. proc winTileProc {menu item} {
  417.     win$item
  418. }
  419.  
  420.  
  421.  
  422.  
  423. menu -n $winMenu -p menuWin {
  424.         "//<Szoom"
  425.         "//<S<I<OsinglePage"
  426.         "<S/;chooseAWindow"
  427.         "/Y<O<Iiconify"
  428.         {menu -n arrange -p winTileProc {
  429.             "/Jvertically^1"
  430.             "/J<O<Ihorizontally^2"
  431.             "tiled^3"
  432.             "overlay^4"
  433.             "(-"
  434.             {menu -n other {
  435.                 {bufferOtherWindow}
  436.                 {chooseAWindow}
  437.                 {chooseWindowStatus}
  438.                 {iconify}
  439.                 {killWindowStatus}
  440.                 {nextWin}
  441.                 {nextWindow}
  442.                 {otherThing}
  443.                 {prevWindow}
  444.                 {shrinkFull}
  445.                 {shrinkHigh}
  446.                 {shrinkLeft}
  447.                 {shrinkLow}
  448.                 {shrinkRight}
  449.                 {singlePage}
  450.                 {swapWithNext}
  451.                 {threeQuarters}
  452.                 {winhorizontally}
  453.                 {winoverlay}
  454.                 {wintiled}
  455.                 {winvertically}
  456.                 {zoom}
  457.             }}}}
  458.         "(-"
  459.         "/msplitWindow"
  460.         "/ntoggleSoftWrap"
  461.         "/otoggleScrollbar"
  462.         "(-"
  463. }
  464.  
  465. # We may be reloading, so add whatever windows we have
  466. if {[info exists winNameToNum]} {
  467.     set nms [array names winNameToNum]
  468.     foreach name $nms {
  469.         regexp {[^:]*$} $name item
  470.         set num $winNameToNum($name)
  471.         if {$num < 10}     {
  472.             addMenuItem -m $winMenu /$num$item
  473.         } else {
  474.             addMenuItem -m $winMenu $item
  475.         }
  476.     }
  477. }
  478.  
  479. insertMenu "File"
  480. insertMenu "Edit"
  481. insertMenu "Text"
  482. insertMenu "Search"
  483. insertMenu "Utils"
  484. #enableMenuItem NamedClipboards paste off
  485. insertMenu "Config"
  486. menu -n $fsetMenuName {}; 
  487. insertMenu $winMenu
  488.  
  489. # catch {insertMenu $helpMenu}
  490.  
  491. # set modeMenus(global) "File Edit Text Search Utils Config $fsetMenuName $winMenu $mailMenu"
  492. # set menuTrans($fsetMenuName) "File Sets"
  493. # set menuTrans($winMenu) "Windows"
  494. # set menuTrans($mailMenu) "Eudora"
  495.  
  496. menu -n $terrMenu {}
  497.  
  498. menu -n $toolserverMenu {}
  499.  
  500.